# -*- coding=utf-8 -*-
'''
Created on Aug 7, 2016

@author: corvo

'''

from sqlalchemy import desc
from Basehandler import BaseHandler
from Database.tables import Express
from Utlis.ReturnCodeConfig import CodeTable
from datetime import datetime, timedelta

delta = 24
class QueryCountHandler(BaseHandler):
    """
    查询信息, 24小时之内的快递数目将会被返回,
    """

    def post(self):
        retjson = {'code':200, 'content':''}

        _info_list = self.db.query(Express)\
            .filter(Express.submittime > datetime.now() - timedelta(hours=delta))\
            .order_by(desc(Express.submittime)) 

        retjson['content'] = _info_list.count()
        self.write_back(retjson)